//
//  MyTableViewCell.m
//  Products_B
//
//  Created by lanou on 16/6/3.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "MyTableViewCell.h"

@interface MyTableViewCell() {
    UILabel *_label;
}

@end

@implementation MyTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
    
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath];
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _label = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 60, 30)];
        _label.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_label];
    }
    return self;
}


// 重写modelArray时全局的indexPath已经有值了，因为indexPah的set方法在此方法之前调用
- (void)setModelArray:(NSArray *)modelArray {
    _modelArray = modelArray;
    if (_indexPath.section != 1) {
        _label.text = modelArray[_indexPath.section];
    } else {
        _label.text = modelArray[1][_indexPath.row];
    }
}


- (void)setIndexPath:(NSIndexPath *)indexPath {
    _indexPath = indexPath;
    
    if (_indexPath.section == 1) {
        if (_indexPath.row == 1) {
            UIImageView *hongbaoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth - 80, (self.frame.size.height - 32 * 140 / 90) / 2, 50, 32 * 140 / 90)];
            [hongbaoImageView sd_setImageWithURL:[NSURL URLWithString:@"http://img.szzhangchu.com/hotpack.jpg"]];
            [self.contentView addSubview:hongbaoImageView];
        }
    }
    if (_indexPath.section == 2) {
        UILabel *numLabel = [[UILabel alloc] initWithFrame:CGRectMake(kWidth - 55, 20, 20, 20)];
        numLabel.text = @"0";
        numLabel.font = [UIFont systemFontOfSize:15];
        numLabel.alpha = 0.6;
        [self.contentView addSubview:numLabel];
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
